/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package my12306.table;

import java.util.HashMap;

/**
 *
 * @author Jack
 */
public class KeyValueItem {

    /**
     * <pre>
     * <option value="1">二代身份证</option>
     * <option value="2">一代身份证</option>
     * <option value="C">港澳通行证</option>
     * <option value="G">台湾通行证</option>
     * <option value="B">护照</option>
     * <option value="1">成人票</option>
     * <option value="2">儿童票</option>
     * <option value="3">学生票</option>
     * <option value="4">残军票</option>
     * <option value="9">商务座</option>
     * <option value="P">特等座</option>
     * <option value="M">一等座</option>
     * <option value="O">二等座</option>
     * <option value="6">高级软卧</option>
     * <option value="4">软卧</option>
     * <option value="3">硬卧</option>
     * <option value="2">软座</option>
     * <option value="1">硬座</option>
     * <option value="-1">无座</option>
     * <option value="7">一等软座</option>
     * <option value="8">二等软座</option>
     * </pre>
     */
    private String desc;
    private String value;
    private final static KeyValueItem TicketAdult = new KeyValueItem("成人票", "1");
    private final static KeyValueItem TicketChildren = new KeyValueItem("儿童票", "2");
    private final static KeyValueItem TicketStudent = new KeyValueItem("学生票", "3");
    private final static KeyValueItem TicketSoldier = new KeyValueItem("残军票", "4");
    private final static KeyValueItem IDSecond = new KeyValueItem("二代身份证", "1");
    private final static KeyValueItem IDFirst = new KeyValueItem("一代身份证", "2");
    private final static KeyValueItem IDHongKong = new KeyValueItem("港澳通行证", "C");
    private final static KeyValueItem IDTaiwan = new KeyValueItem("台湾通行证", "G");
    private final static KeyValueItem IDPassport = new KeyValueItem("护照", "B");
    public final static HashMap<String, KeyValueItem> ids = new HashMap<String, KeyValueItem>();
    public final static HashMap<String, KeyValueItem> tickets = new HashMap<String, KeyValueItem>();

    static {
        tickets.put(TicketAdult.value, TicketAdult);
        tickets.put(TicketChildren.value, TicketChildren);
        tickets.put(TicketSoldier.value, TicketSoldier);
        tickets.put(TicketStudent.value, TicketStudent);
        ids.put(IDFirst.value, IDFirst);
        ids.put(IDHongKong.value, IDHongKong);
        ids.put(IDPassport.value, IDPassport);
        ids.put(IDSecond.value, IDSecond);
        ids.put(IDTaiwan.value, IDTaiwan);
    }

    public KeyValueItem(String key, String value) {
        this.desc = key;
        this.value = value;
    }

    public static KeyValueItem getIDType(String id) {
        return ids.get(id);
    }

    public static KeyValueItem getTicketType(String ticket) {
        return tickets.get(ticket);
    }

    /**
     * @return the key
     */
    public String getKey() {
        return desc;
    }

    /**
     * @param key the key to set
     */
    public void setKey(String key) {
        this.desc = key;
    }

    /**
     * @return the value
     */
    public String getValue() {
        return value;
    }

    /**
     * @param value the value to set
     */
    public void setValue(String value) {
        this.value = value;
    }

    @Override
    public String toString() {
        return desc;
    }

    public String toLongString() {
        return "[" + desc + ":" + value + "]";
    }
}
